﻿<!DOCTYPE html>
<html>
    <head>
        
        <title>登录</title>
        <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
        <meta content="yes" name="apple-mobile-web-app-capable"/>
        <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
        <meta content="telephone=no" name="format-detection"/>
        <link href="css/login.css" rel="stylesheet" type="text/css"/>
		 
	<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.10.0/jquery.js"></script>
		
    </head>
    <body>
        <div class="aui-flexView">

            <div class="aui-scrollView">
                <div class="aui-jop-chang">
                    <p style="font-size: 25px;;">健康体检报告</p>
                </div>
                <div class="aui-jop-top">
                    <div class="aui-jop-top-box">
                            <div class="aui-flex b-line">
                                <div class="aui-form-item">
                                    <img src="images/account.png" alt="">
                                </div>
                                <div class="aui-flex-box">
                                    <input type="tel" id="CardId" placeholder="请输入身份证号">
                                </div>
                            </div>
                            <div class="aui-flex b-line">
                                <div class="aui-form-item">
                                    <img src="images/pass.png" alt="">
                                </div>
                                <div class="aui-flex-box">
                                    <input type="password" id="Pwd" placeholder="密码默认身份证号后六位">
                                </div>
                                <div class="aui-psd">
                                    <a href="javascript:;"><!-- 忘记密码 --></a>
                                </div>
                            </div>
                            <div class="aui-form-button">
                                <button  onclick="login()">登录</button>
                            </div>
                            <div class="aui-register aui-register-a">
                                 
                            </div>
                    </div>
                </div>
                <div class="aui-register">
                     
                </div>

            </div>
            <footer class="aui-footer-link">
                
            </footer>
        </div>
<script>
var islogin=false;
			window.onload = function() {
			// 	var orglist = ['370102D70015003','220171R2'];
			
				var mIdCard = GetCookie("idcard");
			// 	var OrgCold=getQueryString("OrgCold");
			// 	if(null!=OrgCold&&''!=OrgCold){
			// 		if(orglist.includes(OrgCold)){
					islogin = true;
						// SetCookie("OrgCold", OrgCold);
						var resetLogin = getQueryString("resetlogin");
						
						if ("" != mIdCard && null != mIdCard && undefined != mIdCard && resetLogin != '1') {
							window.location.href = "listInfoPage.html"
						}
				// 	}
				// }
				
			}
		
			function login() {
				if(islogin){
					var id =
						/^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|31)|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}([0-9]|x|X)$/
					var card = document.getElementById('CardId');
					var pwd = document.getElementById('Pwd');
					
					if (id.test(card.value) == true) {
						if (card.value.substring(12, 18) == pwd.value) {
							SetCookie("idcard", card.value);
							window.location.href = "listInfoPage.html";
						} else {
							alert('密码不正确')
						}
					} else {
						alert('身份证不正确')
						return;
					}
				}else{
					alert('未授权,请联系管理员！');
				}
				
			}
		
		
			function SetCookie(name, value) {
				var key = '';
				var Days = 2;
				var exp = new Date();
				var domain = "";
				exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
				if (key == null || key == "") {
					document.cookie = name + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() + ";path=/;domain=" + domain +
						";";
				} else {
					var nameValue = GetCookie(name);
					if (nameValue == "") {
						document.cookie = name + "=" + key + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() + ";path=/;domain=" +
							domain + ";";
					} else {
						var keyValue = getCookie(name, key);
						if (keyValue != "") {
							nameValue = nameValue.replace(key + "=" + keyValue, key + "=" + encodeURI(value));
							document.cookie = name + "=" + nameValue + ";expires=" + exp.toGMTString() + ";path=/;domain=" + domain + ";";
						} else {
							document.cookie = name + "=" + nameValue + "&" + key + "=" + encodeURI(value) + ";expires=" + exp.toGMTString() +
								";path=/;" + domain + ";";
						}
					}
				}
			}
			
			function GetCookie(name) {
			    var nameValue = "";
			    var key = "";
			    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
			    if (arr = document.cookie.match(reg)) {
			        nameValue = decodeURI(arr[2]);
			    }
			    if (key != null && key != "") {
			        reg = new RegExp("(^| |&)" + key + "=([^(;|&|=)]*)(&|$)");
			        if (arr = nameValue.match(reg)) {
			            return decodeURI(arr[2]);
			        }
			        else return "";
			    }
			    else {
			        return nameValue;
			    }
			}
			
			function getQueryString(name) {
				var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
				var r = window.location.search.substr(1).match(reg);
				if (r != null) {
					return unescape(r[2]);
				}
				return null;
			}
		</script>
    </body>
</html>
